<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">
    <meta content=always name=referrer>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/base.css">
    <title>修改昵称</title>
</head>
<body>
<form action="" method="post" id="form_1" >
<div class="wrap-shopname">
    <div class="header">
        <p>修改昵称</p>
        <img src="__STATIC__/img_user/back.png" class="back" onclick=window.location.href="{:url('mobile/user_info/self_information')}">
        <span><a id="save">保存</a></span>
    </div>
    <div class="name">
        <input type="text" value="{:input('nickname','')}" name="nickname" nullmsg="昵称不能为空" datatype="s2-20" errormsg="昵称格式不正确">
        <img src="__STATIC__/img_user/close.png" onclick="$(this).prev().val('')">
    </div>
    <p class="tip">2-20个字符，可由中英文、数字组成</p>
</div>
</form>
{include file="public/src" /}
<script>
    //验证表单元素
    $(function () {
        $.Tipmsg.r = null;
        $.Tipmsg.p = null;
        $.Datatype.s4_20 = /^[\u4E00-\u9FA5\uf900-\ufa2d\w\.\s]{4,20}$/;
        var demo = $("#form_1").Validform({
            btnSubmit: '#save',
            tiptype: function (msg) {
                layer.open({content: msg, skin: 'msg', time: 2});
            },
            tipSweep: true,
            ajaxPost: true,
            callback: function (t) {
                if (t.code == 200) {
                    layer.open({content: t.message, skin: 'msg', time: 2});
                    setTimeout(function () {   //修改成功跳转回个人信息
                        window.location.href="self_information";
                    }, 1000);
                } else {
                    layer.open({content: t.message, skin: 'msg', time: 2});
                }
            }
        });
        demo.config({
            ajaxpost:{
                error: function () {
                    layer.open({content:'您的手机网络信号不好',skin:'msg',time:2});
                }
            }
        })
    });
</script>
</body>
</html>